class Activity < ApplicationRecord
    has_many :comments, dependent: :destroy, foreign_key: :activity_id
    has_and_belongs_to_many :users, join_table: "activities_users"
    validates :title, presence: true, length: { minimum: 2, maximum: 50 }
    validates :from, presence: true
    validates :to, presence: true
    validates :starttime, presence: true
    validates :endtime, presence: true
    validates :typ_e, presence: true
    validates :currents, presence: true
    validates :sum, presence: true
    validates_numericality_of(:currents ,:only_integer =>true,:greater_than =>0,:less_than => 1000)
    validates_numericality_of(:sum ,:only_integer =>true,:greater_than =>0,:less_than => 1000)
    validates :description, presence: true
end
